/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ecfdb;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author SIDALI
 */
@Entity
@Table(name = "depot", catalog = "mandataire", schema = "")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Depot.findAll", query = "SELECT d FROM Depot d"),
    @NamedQuery(name = "Depot.findByIddepot", query = "SELECT d FROM Depot d WHERE d.iddepot = :iddepot"),
    @NamedQuery(name = "Depot.findByQuantite", query = "SELECT d FROM Depot d WHERE d.quantite = :quantite"),
    @NamedQuery(name = "Depot.findByDate", query = "SELECT d FROM Depot d WHERE d.date = :date"),
    @NamedQuery(name = "Depot.findByVendu", query = "SELECT d FROM Depot d WHERE d.vendu = :vendu")})
public class Depot implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "iddepot", nullable = false)
    private Integer iddepot;
    @Column(name = "quantite")
    private Integer quantite;
    @Column(name = "date")
    @Temporal(TemporalType.TIMESTAMP)
    private Date date;
    @Column(name = "vendu", length = 4)
    private String vendu;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "depot")
    private List<Facture> factureList;
    @OneToMany(mappedBy = "depot")
    private List<LegumesDepot> legumesDepotList;
    @JoinColumn(name = "id_legume", referencedColumnName = "idlegumes")
    @ManyToOne
    private Legumes idLegume;
    @JoinColumn(name = "id_fellah", referencedColumnName = "idfellah")
    @ManyToOne
    private Fellah idFellah;
    @OneToMany(mappedBy = "idDepot")
    private List<CreditFellah> creditFellahList;

    public Depot() {
    }

    public Depot(Integer iddepot) {
        this.iddepot = iddepot;
    }

    public Integer getIddepot() {
        return iddepot;
    }

    public void setIddepot(Integer iddepot) {
        this.iddepot = iddepot;
    }

    public Integer getQuantite() {
        return quantite;
    }

    public void setQuantite(Integer quantite) {
        this.quantite = quantite;
    }

    public Date getDate() {
        return date;
    }

    public void setDate(Date date) {
        this.date = date;
    }

    public String getVendu() {
        return vendu;
    }

    public void setVendu(String vendu) {
        this.vendu = vendu;
    }

    @XmlTransient
    public List<Facture> getFactureList() {
        return factureList;
    }

    public void setFactureList(List<Facture> factureList) {
        this.factureList = factureList;
    }

    @XmlTransient
    public List<LegumesDepot> getLegumesDepotList() {
        return legumesDepotList;
    }

    public void setLegumesDepotList(List<LegumesDepot> legumesDepotList) {
        this.legumesDepotList = legumesDepotList;
    }

    public Legumes getIdLegume() {
        return idLegume;
    }

    public void setIdLegume(Legumes idLegume) {
        this.idLegume = idLegume;
    }

    public Fellah getIdFellah() {
        return idFellah;
    }

    public void setIdFellah(Fellah idFellah) {
        this.idFellah = idFellah;
    }

    @XmlTransient
    public List<CreditFellah> getCreditFellahList() {
        return creditFellahList;
    }

    public void setCreditFellahList(List<CreditFellah> creditFellahList) {
        this.creditFellahList = creditFellahList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (iddepot != null ? iddepot.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Depot)) {
            return false;
        }
        Depot other = (Depot) object;
        if ((this.iddepot == null && other.iddepot != null) || (this.iddepot != null && !this.iddepot.equals(other.iddepot))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return getIdFellah().getNom() + " " + getDate();
    }
    
}
